Skip to content

Conversation

T0nd0Tara
Copy link

Although this is not a problem in the regular format, when trying to create custom types based on the RouteConfig type. I cannot set the status code to a number.

for example creating the custom type

type KeyValueUnion<T> = {
  [K in keyof T]: { status: K, result: T[K] }
}[keyof T];

type IRoute<I = RouteConfig['request'], O = RouteConfig['responses']> = Omit<RouteConfig, 'request' | 'responses'> & {
  request: I,
  responses: O,

  func: (input: I) => Promise<KeyValueUnion<O>>
}

For easier integration with express, It wants the status code to be a string. (as now I don't use the status code as a key to an object, but as a value of an object)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant